package com.zenith.zongheng.demo.controller;


import com.zenith.zongheng.common.domain.vo.PageVO;
import com.zenith.zongheng.demo.domain.vo.LeaveProcessVO;
import com.zenith.zongheng.logs.annotation.Log;
import com.zenith.zongheng.logs.enums.LogOptTypeEnum;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.zenith.zongheng.demo.domain.dto.LeaveProcessDTO;
import com.zenith.zongheng.demo.domain.dto.LeaveProcessSaveDTO;
import com.zenith.zongheng.demo.api.LeaveProcessService;
import com.zenith.zongheng.core.result.R;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tangzx
 * @since 2021-12-28
 */
@RestController
@RequestMapping("/leaveProcess")
public class LeaveProcessController {
    @Autowired
    @Reference
    private LeaveProcessService leaveProcessService;


    @PostMapping("/save")
    public R<Object> createLeaveProcess(@RequestBody LeaveProcessSaveDTO dto) {
        leaveProcessService.saveLeaveProcess(dto);
        return R.ok();
    }

    @PostMapping("/update")
    public R<Object> updateLeaveProcess(@RequestBody LeaveProcessSaveDTO dto) {
        leaveProcessService.updateLeaveProcess(dto);
        return R.ok();
    }

    @PostMapping("/delete")
    public R<Object> deleteLeaveProcess(@RequestBody Long... ids) {
        leaveProcessService.deleteLeaveProcess(ids);
        return R.ok();
    }

    @GetMapping("/getById/{id}")
    public R<Object> getById(@PathVariable Long id) {
        return R.ok(leaveProcessService.getById(id));
    }


    /**
     * 办理流程
     *
     * @author: wuyue
     * @param dto 请假过程dto
     * @return 请假流程表通过时间遍历
     */
    @Log(value = "假条ID", module = "leave", optType = LogOptTypeEnum.OPERATE_QUERY)
    @PostMapping("/list")
    public R<PageVO<LeaveProcessVO>> list(@RequestBody(required = false) LeaveProcessDTO dto) {
        return R.ok(leaveProcessService.queryPage(dto));
    }

}

